import { init, webSocketLink } from '@/utils/webSocket'
import tool from '@/utils/tool'
// 状态
const state = {
  socketTask: null // scoket连接
}


const mutations = {
  WEB_SOCKET_LINK (state, data) {
    state.socketTask = data
  }
}

const actions = {
  // 初始化登录
  webSocketInit ({ commit, state }) {
    if (tool.cookie.get("TOKEN") && state.socketTask == null) {
      init()
      commit('WEB_SOCKET_LINK', webSocketLink)
    }
  }
}

export default {
  namespaced: true,
  state,
  mutations,
  actions
}
